package com.lnking.lnkingplace.model.dto.inspect;

import com.lnking.lnkingplace.service.impl.InspectServiceImpl;
import com.lnking.starter.export.annotation.TableColumn;
import com.lnking.starter.export.annotation.TableInfo;
import com.lnking.starter.mybatis.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;

/**
 * @program: lnking-place
 * @description:
 * @author: LDQ
 * @create: 2022-09-16 15:29
 **/
@Data
@TableInfo(tableName = "检查信息导出")
public class InspectExportDto extends BaseEntity {

    @TableColumn(columnName = "场所类型",column = "0")
    private String street;

    @TableColumn(columnName = "场所类型",column = "1")
    private String placeType;

    @TableColumn(columnName = "检查单位",column = "2")
    private String placeName;

    private String placeId;

    private String inspectResult;

    @TableColumn(columnName = "检查时间",column = "3")
    private LocalDateTime inspectTime;


    @ApiModelProperty(value = "隐患情况")
    @TableColumn(columnName = "隐患情况",column = "4")
    private String hiddenDanger;

    @ApiModelProperty(value = "整改措施")
    @TableColumn(columnName = "整改措施",column = "5")
    private String rectificationMeasures;

    @ApiModelProperty(value = "备注")
    @TableColumn(columnName = "备注",column = "6")
    private String rectificationContent;

    @TableColumn(columnName = "检查结果图片",column = "7",img = "images")
    private String rectificationPhotos;

    @TableColumn(columnName = "督察类型",column = "8")
    private String inspectType;

    @TableColumn(columnName = "整改情况",column = "9")
    private String placeContent;

    @TableColumn(columnName = "整改图片",column = "10",img = "images")
    private String placePhotos;

    @TableColumn(columnName = "检查小组",column = "11")
    private String groupNames;

    @TableColumn(columnName = "检查人",column = "12")
    private String inspectPersonName;

    public String getRectificationPhotos() {
        String s = StringUtils.substringAfter(rectificationPhotos, "\"url\":\"");
        return StringUtils.substringBefore(s,"\"");

    }

    public String getPlacePhotos() {
        String s = StringUtils.substringAfter(placePhotos, "\"url\":\"");
        return StringUtils.substringBefore(s,"\"");
    }

    public String getHiddenDanger() {
        if(inspectResult.equals(InspectServiceImpl.CLOSED)){
        return  InspectServiceImpl.CLOSED;
        }else if(inspectResult.equals(InspectServiceImpl.Noproblem)||inspectResult.equals(InspectServiceImpl.OK)){
            return  InspectServiceImpl.Noproblem;
        }else if(inspectResult.equals(InspectServiceImpl.NOTOPEN)){
            return  InspectServiceImpl.NOTOPEN;
        }else if(inspectResult.equals(InspectServiceImpl.ADDRESS)){
            return  InspectServiceImpl.ADDRESS;
        }
        return hiddenDanger;
    }

    public String getRectificationMeasures() {
        if(inspectResult.equals(InspectServiceImpl.Noproblem)||inspectResult.equals(InspectServiceImpl.OK)){
            return  "保持";
        }
        return rectificationMeasures;
    }

}
